home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BMUG Revelations
/
BMUG Revelations.toast
/
Programming
/
Programming Languages
/
Yerk 3.64
/
Supplement
/
Unsupported
/
Optionals
/
lex
< prev
next >
Wrap
Text File
|
1986-02-10
|
3KB
|
155 lines
\ 9/10/84 RW Version 1
\ 2/09/86 cdn Changed to use Oredered-Col
\ Added SAY sentence structures
\ Sentence generator
\ This is a sentence generator using ATN and
\ randomly selected patterns.
\ PARTSPEECH - This offers a data region designed to serve as a
\ relatively space efficient word dictionary
1 Value cap
75 Value LineLen
:CLASS PartSpeech <Super Ordered-Col
\ ( str255 -- ) address of string to enter in dictionary
:M ADD: count
heap> BasicStr dup add: super
put: [ new: [ dup ] ]
;M
\ an offset into StrSpace
:M PRINT: ( index -- )
get: [ at: super ]
dup 1+ out + LineLen > IF cr 0 -> out THEN space \ line full
cap \ Capitalize first letter in sentence
IF over c@ dup 96 > over 123 < and IF 32 - THEN emit
swap 1+ swap 1-
0 -> cap
THEN
type
;M
:M RANDOM: ( -- )
size: super random print: self
;M
:M LIST:
size: super 0
DO
i print: self CR
0 -> out
LOOP
;M
:M DISPOSE:
size: super 0
DO
i dispose: super
LOOP
;M
;CLASS
5 PartSpeech Art \ Articals
50 PartSpeech Adj \ Adjectives
50 PartSpeech Noun \ Nouns
50 PartSpeech commNoun \ Common Nouns
50 PartSpeech propNoun \ Proper Nouns
50 PartSpeech collNoun \ Collective Nouns
50 PartSpeech absNoun \ Abstract Nouns
25 PartSpeech Pron \ Pronouns
10 PartSpeech posPron \ Possessive Pronouns
5 PartSpeech relPron \ Relative Pronoun
50 PartSpeech Verb \ Verbs
15 PartSpeech auxVerb \ Auxiliary Verbs
10 PartSpeech linkVerb \ Linking Verbs
50 PartSpeech Adv \ Adverbs
10 PartSpeech conjAdv \ Conjuctive Adverb
10 PartSpeech Conj \ Conjunctions
50 PartSpeech Prep \ Prepositions
\ Dispose of all string space occupied by PartSpeech objects
: ?disp
drop dup @ ' PartSpeech =
IF dispose: [ >body ] ELSE drop THEN
;
: disp
'c ?disp 0 trav
;
// lexicon
: EOS ." . " 1 -> cap ;
10 Ordered-Col Sentence
: sentence1
random: art
random: adj
random: noun
random: verb
random: prep
random: art
random: noun
EOS
; latest name> add: Sentence
: sentence2
random: propnoun
random: conj
random: pron
random: verb
random: prep
random: art
random: adj
random: noun
EOS
; latest name> add: Sentence
: sentence3
random: pron
random: verb
random: adj
random: noun
random: prep
random: pospron
random: noun
EOS
; latest name> add: Sentence
: sentence4
random: art
random: noun
random: relpron
random: verb
random: pron
random: verb
random: prep
random: art
random: noun
random: relpron
random: verb
random: adj
random: noun
; latest name> add: Sentence
( size -- )
: paragraph
cr 0 -> out
0 DO size: Sentence random exec: Sentence LOOP cr
;
\ ( lo hi -- val ) Generate random number in the range
: rnd over - 1+ random + ;
\ Generate chapters for the Neon manual
: Short-Story
3 4 rnd 0 \ 3 to 4 paragraphs
DO
4 7 rnd paragraph \ 4 to 7 sentences each
LOOP
;